package top.vanchor.myblog2back.controller.admin;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import top.vanchor.myblog2back.entity.BlogDealRecord;
import top.vanchor.myblog2back.entity.BlogReport;
import top.vanchor.myblog2back.service.IBlogDealRecordService;

import javax.annotation.Resource;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Ding
 * @create 2022/2/20 19:27
 */
@Api("处理用户申请控制器")
@RestController
@RequestMapping("/admin/dealUserApply")
public class DealUserApply {

    @Resource
    private IBlogDealRecordService service;

    @ApiOperation("举报、意见处理结果记录")
    @GetMapping("/getList")
    @ResponseBody
    public JSONObject getList(
            @RequestParam("pageNo") Integer pageNo,
            @RequestParam("pageSize") Integer pageSize,
            @RequestParam("deal_type") Integer dealType,//0举报，1建议
            @RequestParam("report_type") Integer reportType,//0举报用户，1举报博客，2举报评论
            @RequestParam("status") Integer status//通过1-未通过2
    ){
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonTemp = new JSONObject();
        PageInfo<BlogDealRecord> list = new PageInfo<>();
        try {
            list = service.getList(pageNo,pageSize,dealType,reportType,status);
            jsonObject.put("code",200);
            jsonObject.put("msg","获取成功");
            jsonTemp.put("list",list.getList());
            jsonTemp.put("total",list.getTotal());
            jsonObject.put("data",jsonTemp);
        }catch (Exception e){
            e.printStackTrace();
            jsonObject.put("code",500);
            jsonObject.put("msg","服务器异常，请求失败");
        }
        return jsonObject;
    }
}
